package com.sy.department.utils;

/**
 * 数据返回工具类
 */
public class ResultUtils {
    /**
     * 无参数返回
     */
    public static ResultVo<Void> success() {
        return Vo(null, StatusCode.SUCCESS_CODE, null);
    }

    public static ResultVo<Void> success(String msg) {
        return Vo(msg, StatusCode.SUCCESS_CODE, null);
    }

    /**
     * 返回带参数
     */
    public static <T> ResultVo<T> success(String msg, T data) {
        return Vo(msg, StatusCode.SUCCESS_CODE, data);
    }

    public static <T> ResultVo<?> success(String msg, int code, T data) {
        return Vo(msg, code, data);
    }

    public static <T> ResultVo<T> Vo(String msg, int code, T data) {
        return new ResultVo<T>(msg, code, data);
    }

    /**
     * 错误返回
     */
    public static ResultVo<?> error() {
        return Vo(null, StatusCode.ERROR_CODE, null);
    }

    public static ResultVo<?> error(String msg) {
        return Vo(msg, StatusCode.ERROR_CODE, null);
    }

    public static ResultVo<?> error(String msg, int code, Object data) {
        return Vo(msg, code, data);
    }

    public static ResultVo<?> error(String msg, int code) {
        return Vo(msg, code, null);
    }

    public static ResultVo<?> error(String msg, Object data) {
        return Vo(msg, StatusCode.ERROR_CODE, data);
    }
}
